﻿#include <iostream>
#include <thread>
#include <math.h>

#include <zmq.hpp>
#include <spdlog/spdlog.h>

int main()
{
	zmq::context_t ctx;
	zmq::socket_t publisher = zmq::socket_t(ctx, ZMQ_PUB);
	publisher.bind("tcp://*:5556");

	while (true) {
		int zipcode = std::rand() % 10000;
		int temperature = std::rand() % 215 - 80;
		int relhumidity = std::rand() % 50 + 10;

		std::string msg = fmt::format("{:04d} {} {}", zipcode, temperature, relhumidity);
		publisher.send(msg.data(), msg.size());
		//std::this_thread::sleep_for(std::chrono::microseconds(1));
	}
}